#ifndef TEXTURE_2D_H_
#define TEXTURE_2D_H_

#include <memory>
#include "render_system/basic_define.h"
#include "render_system/gl_render_system_define.h"

class Texture2D
{
public:
    GL_RENDER_SYSTEM_API Texture2D();

    GL_RENDER_SYSTEM_API ~Texture2D();

    GL_RENDER_SYSTEM_API void setActiveID(const size_t activeID); // must be in [0,31]

    GL_RENDER_SYSTEM_API void active();

    GL_RENDER_SYSTEM_API void deActive();

    GL_RENDER_SYSTEM_API void bind();

    GL_RENDER_SYSTEM_API void unbind();

    GL_RENDER_SYSTEM_API void read(
        const size_t uWidth,
        const size_t uHeight,
        const PixelFormat& pixelformat,
        const void* pData);

    // properties
    GL_RENDER_SYSTEM_API size_t ID() const;

    GL_RENDER_SYSTEM_API size_t width() const;

    GL_RENDER_SYSTEM_API size_t height() const;

    GL_RENDER_SYSTEM_API PixelFormat pixelFormat() const;

    GL_RENDER_SYSTEM_API size_t glFormat() const;

    GL_RENDER_SYSTEM_API size_t glConponentType() const;

    GL_RENDER_SYSTEM_API size_t channels() const;

private:
    void _copy2gpu();

private:
    size_t                _uID;
    size_t                _activeID;
    size_t                _uWidth;
    size_t                _uHeight;
    PixelFormat           _pixelFormat;
    std::shared_ptr<char> _pData;
};

typedef std::shared_ptr<Texture2D> Texture2DPtr;

#endif